package com.wshl.aijiuunion.utils;

import android.support.v7.app.AppCompatActivity;

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.ToastUtils;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.wshl.aijiuunion.GlobConstant;
import com.wshl.aijiuunion.R;
import com.wshl.aijiuunion.view.widget.Loadingdialog;


import org.json.JSONObject;

/**
 * Created buy 风凊扬 on 2019/7/9 0009
 */
public class Simplame extends AppCompatActivity {

    private void collect(String url, boolean isCollect) {






        if (!NetworkUtils.isConnected()) {
            ToastUtils.showLong(getString(R.string.neterror));
            return;
        }
        Loadingdialog.showAlert(this);
        String token = SPUtils.getInstance().getString(GlobConstant.TOKEN);
        OkGo.<String>post(url)
                .params(GlobConstant.TOKEN, token)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        Loadingdialog.dismiss();
                        LogUtils.i("接口数据:" + response.body());
                        try {
                            JSONObject jsonObject = new JSONObject(response.body());
                            if (jsonObject.has("code")) {
                                String code = jsonObject.getString("code");
                                switch (code) {
                                    case GlobConstant.REQUESTSUCCESS:

                                        break;
                                    case GlobConstant.REQUESTERROR://token过期失效
                                        // LoginOutUtils.reLogin(TalkDetailsActivity.this);
                                        break;
                                    default:
                                        if (jsonObject.has("msg")) {
                                            ToastUtils.showLong(jsonObject.getString("msg"));
                                        }
                                        break;
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        Loadingdialog.dismiss();
                    }
                });










    }
}
